 use "$data\women_analysis.dta", clear

 global controlkid childageyears female genderage birthorder
 global controlwoman mbase_ageyears  fdstotal rantime ranerror numberkids
 global controlhh land members adults mbase_electrified  mbase_OB mbase_scheduled

 estimates clear
 foreach i in totletterspm_child totsylpm_child totwordpm_child totnonwordpm_child totgrade1wpm_child totgrade2wpm_child ///
 numq1tot numq2tot numq3tot numq4tot numq5tot numq6tot numq7tot numq8tot Mathtot_child{
  ivregress 2sls `i' (participatedTA_IV=ITTanalysis) i.strata $controlkid $controlwoman $controlhh, cluster(learnerid)
  est store `i'
  su `i' if ITTanalysis==0
  estadd scalar controlmean=`r(mean)'
  global controlmean=r(mean)
  global sd1=r(sd)
  global n1=r(N)
  su `i' if ITTanalysis==1
  global treatmean=r(mean)
  global sd2=r(sd)
  global n2=r(N)
  power twomeans $controlmean $treatmean, sd1($sd1) sd2($sd2) n1($n1) n2($n2)
  estadd scalar power=`r(power)'
}

esttab *  using "$results/TableB9.xls", stat(power controlmean N r2) b(3) ci(3) keep(participatedTA_IV) replace 


 exit
